
package com.myway.core.common;

import java.util.HashMap;


/**
 *@author 陈建海(jianh_chen)
 *@description
 *
 * 项目类型
 *
 *@date 2009-7-24
 */
public enum XCDItemType
{

	/**
	 * 行程单

	 */
	XCD("XCD"),
	/**
	 * 邮件寄费
	 */
	MAILINGFEE("MAILINGFEE"),
	/**
	 * 押金
	 */
	DEPOSIT("DEPOSIT"),
	/**
	 * 罚金
	 */
	FINE("FINE"),
	/**
	 * 保价费

	 */
	BJF("BJF");
	/**
	 * Alias name. This is the name which will be stored in database.
	 */
	private final String alias;

	/**
	 * A hash map which keep all the action enum with alias name as key.
	 */
	private static HashMap<String, XCDItemType> map;

	/**
	 * Construct the hash map at load time
	 */
	static 
	{
		map = new HashMap<String, XCDItemType>();
		for (XCDItemType type : XCDItemType.values()) {
			map.put(type.alias, type);
		}
	}

	XCDItemType(String alias) 
	{
		this.alias = alias;
	}

	@Override
	public String toString()
	{
		return this.alias;

	}

	/**
	 * Return a <code>Action</code> object holding the value of specified alias name
	 *
	 * @param alias
	 *            the alias name of the type
	 *
	 * @return a <code>Action</code> object holding the value represented by the alias name
	 *         argument
	 */
	public static XCDItemType valueOfAlias(String alias)
	{
		XCDItemType type = map.get(alias);

		if (type == null) {
			throw new IllegalArgumentException("Unknown action alias [" + alias + "]");
		}

		return type;
	}

	/**
	 * @return the alias
	 */
	public String getAlias() {
		return this.alias;
	}
	
}
